home *** CD-ROM | disk | FTP | other *** search
- #ifndef __PRINTJPEG__
- #define __PRINTJPEG__
-
- #include <ImageCompression.h>
-
- struct JPEGImage {
- Handle theData; /*the Data Handle*/
- Rect theBounds; /* the Bounds of the Image */
- ImageDescriptionHandle theDesc; /* an ImageDescriptionHandle */
- };
- typedef struct JPEGImage JPEGImage;
-
- // macro for determining if the port is a color port.
- #define ISCOLORPORT(gPort) (((gPort)->portBits.rowBytes & 0x8000) != 0)
-
-
- /*
- JPEG Marker code definitions.
- */
- #define MARKER_PREFIX 0xff
- #define MARKER_SOI 0xd8 /* start of image */
- #define MARKER_SOF 0xc0 /* start of frame codes */
- #define MARKER_DHT 0xc4 /* define Huffman table */
- #define MARKER_EOI 0xd9 /* end of image */
- #define MARKER_SOS 0xda /* start of scan */
- #define MARKER_DQT 0xdb /* define quantization tables */
- #define MARKER_DNL 0xdc /* define quantization tables */
- #define MARKER_DRI 0xdd /* define Huffman table */
- #define MARKER_COM 0xfe /* comment */
- #define MARKER_APP0 0xe0
-
-
- //=====================================================================================
- // Public interface function prototypes
- //=====================================================================================
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- static OSErr ReadJPEGData(FSSpec *theSpec, Handle *theData);
-
- static OSErr SetJPEGBounds(JPEGImage * theJPEGImage);
-
- static OSErr MakeJPEGImageDescription(JPEGImage *theJPEGImage);
-
- static char *
- MarkerDetect(char *data,short *width,short *height,long *hRes,long *vRes,short *depth);
-
- static void SwallowQuantTable(char *data);
-
- static void SwallowHuffTable(char *data);
-
- static OSErr DrawJPEGImage(JPEGImage theJPEGImage, Boolean isColorPort);
-
- SInt16 main(void);
- static OSErr initMacintosh(void);
- static OSErr SetupMenus(void);
- static SInt16 handleEvent(void);
- static OSErr Print(JPEGImage theJPEGImage, THPrint aPrintRecordHandle);
- static void DoKeyDown(EventRecord *);
- static void doCommand(SInt16,SInt16);
- static void showAboutMeDialog(void) ;
- static void DoTheOpenCommand(void);
-
- #ifdef __cplusplus
- }
- #endif
-
- /*
- * Resource ID constants.
- */
- #define kAppleMenuID 128 /* This identifies the apple menu*/
- #define kFileMenuID 129
- #define kEditMenuID 130
-
- // Apple Menu Item Numbers
- #define kAboutMeCommand 1
-
- // File Menu Item Numbers
- #define kOpenCommand 1
- #define kSaveCommand 2
- // separator line 3
- #define kPageSetupCommand 4
- #define kPrintCommand 5
- // separator line 6
- #define kQuitCommand 7
-
- /*
- * Support for the About Dialog
- */
- #define kAboutMeDLOG 128
- #define kOKButton 1
-
- // alert dialog ID to report problems to users.
- #define kGenericError 128
-
- // define for flags value for calls to StdPix bottleneck.
- #define kCallOldBits (1 << 0)
- #define kCallStdBits (1 << 1)
-
- #define MIN(x,y) ( x > y ) ? y : x
-
- #define kSleepTime 5
- #define kInsetBits 10
-
- // Application Specific Errors
- #define kAppError 4017
- #define iNotJPEGData 4019
- #define kCouldntLoadMenu 4020
-
- #endif
-